package ru.mipt.sport.gui.competition;

import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import javax.swing.*;
import ru.mipt.sport.model.entity.CompetitionSportEntity;
import ru.mipt.sport.model.entity.CompetitionStageEntity;
import ru.mipt.sport.model.entity.SelectionCriteriaEntity;
import ru.mipt.sport.model.entity.SportSpecializationEntity;
import ru.mipt.sport.model.interfaces.CompetitionSport;
import ru.mipt.sport.model.interfaces.CompetitionStage;
import ru.mipt.sport.model.interfaces.SportSpecialization;
import ru.mipt.sport.utils.DBUtils;

/**
 *
 * @author Danon
 */
public class AddCompetitionSportDialog extends javax.swing.JDialog {

    private final DBUtils db = DBUtils.getInstance();
    
    /**
     * A return status code - returned if Cancel button has been pressed
     */
    public static final int RET_CANCEL = 0;
    /**
     * A return status code - returned if OK button has been pressed
     */
    public static final int RET_OK = 1;

    /**
     * Creates new form AddCompetitionSportDialog
     */
    public AddCompetitionSportDialog(java.awt.Frame parent, boolean modal, CompetitionSport sport) {
        super(parent, modal);
        initComponents();

        // Close the dialog when Esc is pressed
        String cancelName = "cancel";
        InputMap inputMap = getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
        inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), cancelName);
        ActionMap actionMap = getRootPane().getActionMap();
        actionMap.put(cancelName, new AbstractAction() {

            public void actionPerformed(ActionEvent e) {
                doClose(RET_CANCEL);
            }
        });
        
        refreshSportsList();
        
        if(sport!=null)
            this.sport = sport;
        else this.sport = new CompetitionSportEntity();
        if(this.sport.getId()==null) {
            setTitle("New competition sport...");
            addDefaultStage();
        } else {
            setTitle("Edit competition sport...");
            fillForm();
        }
    }

    /**
     * @return the return status of this dialog - one of RET_OK or RET_CANCEL
     */
    public int getReturnStatus() {
        return returnStatus;
    }

    public CompetitionSport getSport() {
        return sport;
    }

    public List<CompetitionStage> getStages() {
        return stages;
    }
    
    private void fillForm() {
        nameTF.setText(sport.getName());
        sportCB.setSelectedItem(sport.getSpecialization());
        if(sport.getDate()!=null)
            dateSpinner.setValue(sport.getDate());
        if(sport.getPeoplePerRun()>0)
            maxPeopleSpinner.setValue(sport.getPeoplePerRun());
        else {
            maxPeopleSpinner.setValue(0); // <= 0 means unlimited (unspecified)
            jCheckBox1.setSelected(true);
        }
    }
    
    private void addDefaultStage() {
        DefaultListModel<CompetitionStage> model = (DefaultListModel<CompetitionStage>)jList1.getModel();
        if(model!=null) {
            CompetitionStage s = new CompetitionStageEntity();
            s.setIndex(0);
            s.setName("Final Stage (default)");
            s.setDescription("Default final stage");
            s.setCriteria(null);
            model.addElement(s);
        }
    }
    
    private void processInput() {
        sport.setName(nameTF.getText());
        if((Integer)maxPeopleSpinner.getValue() < 0) sport.setPeoplePerRun(0);
        else sport.setPeoplePerRun((Integer)maxPeopleSpinner.getValue());
        sport.setDate((Date)dateSpinner.getValue());
        sport.setSpecialization((SportSpecializationEntity)sportCB.getSelectedItem());
        stages.clear();
        ListModel<CompetitionStage> model = jList1.getModel();
        if(model!=null) {
            for(int i=0; i<model.getSize(); i++)
                stages.add((CompetitionStage)model.getElementAt(i));
        }
        // TODO: process people (jury, visitors, observants, guests, etc)
    }
    
    private void refreshSportsList() {
        EntityManager em = db.getEntityManager();
        Query q = em.createQuery("SELECT s FROM SportSpecializationEntity s", SportSpecialization.class);
        List<SportSpecialization> sports = q.getResultList();
        DefaultComboBoxModel model = (DefaultComboBoxModel)sportCB.getModel();
        model.removeAllElements();
        for(SportSpecialization s : sports) {
            model.addElement(s);
        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        okButton = new javax.swing.JButton();
        cancelButton = new javax.swing.JButton();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jLabel10 = new javax.swing.JLabel();
        nameTF = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        sportCB = new javax.swing.JComboBox();
        jLabel2 = new javax.swing.JLabel();
        maxPeopleSpinner = new javax.swing.JSpinner();
        jLabel3 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        dateSpinner = new javax.swing.JSpinner();
        jCheckBox1 = new javax.swing.JCheckBox();
        jPanel2 = new javax.swing.JPanel();
        jLabel11 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jList1 = new javax.swing.JList();
        addStageButton = new javax.swing.JButton();
        removeStageButton = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Add sport to the Competition...");
        setMinimumSize(new java.awt.Dimension(320, 300));
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                closeDialog(evt);
            }
        });

        okButton.setText("OK");
        okButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                okButtonActionPerformed(evt);
            }
        });

        cancelButton.setText("Cancel");
        cancelButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelButtonActionPerformed(evt);
            }
        });

        jLabel10.setText("<html>\n<p>\n    <strong>\n       Specify general information about sport specialization of the competition.\n    </strong><br/>\n     You have to define sport specialization and maximum number of people that can take part in a single run.\n</p>\n</html>");
        jLabel10.setVerticalTextPosition(javax.swing.SwingConstants.TOP);

        jLabel1.setLabelFor(nameTF);
        jLabel1.setText("Name:");

        sportCB.setModel(new DefaultComboBoxModel<SportSpecialization>());

        jLabel2.setLabelFor(sportCB);
        jLabel2.setText("Sport:");

        maxPeopleSpinner.setModel(new javax.swing.SpinnerNumberModel(0, 0, 1000, 1));
        maxPeopleSpinner.setEnabled(false);

        jLabel3.setText("Max. number of people per run:");

        jLabel5.setText("Approximate date:");

        dateSpinner.setModel(new javax.swing.SpinnerDateModel());
        dateSpinner.setEditor(new javax.swing.JSpinner.DateEditor(dateSpinner, "dd.MM.yyyy HH:mm"));

        jCheckBox1.setSelected(true);
        jCheckBox1.setText("Unlimited");
        jCheckBox1.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                jCheckBox1StateChanged(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel10, javax.swing.GroupLayout.DEFAULT_SIZE, 426, Short.MAX_VALUE)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel1)
                                    .addComponent(jLabel2))
                                .addGap(18, 18, 18)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(nameTF)
                                    .addComponent(sportCB, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                        .addGap(10, 10, 10))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel3)
                                .addGap(18, 18, 18)
                                .addComponent(maxPeopleSpinner, javax.swing.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel5)
                                .addGap(18, 18, 18)
                                .addComponent(dateSpinner)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jCheckBox1)
                        .addGap(0, 0, Short.MAX_VALUE))))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(nameTF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(sportCB, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(dateSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(maxPeopleSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3)
                    .addComponent(jCheckBox1))
                .addContainerGap(30, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("1. General settings", jPanel1);

        jLabel11.setText("<html>\n<p>\n    <strong>\n       Predefine the stages of the sport specialization in the competition.\n    </strong><br/>\n     A simple competitions always has one stage (the final one). You can also add \"1/2 Final\" and \"1/4 final\" stages\n</p>\n</html>");
        jLabel11.setVerticalTextPosition(javax.swing.SwingConstants.TOP);

        jLabel4.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel4.setText("Stages:");

        jList1.setModel(new DefaultListModel<CompetitionStage>());
        jList1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jList1MouseClicked(evt);
            }
        });
        jList1.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                jList1ValueChanged(evt);
            }
        });
        jList1.addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentShown(java.awt.event.ComponentEvent evt) {
                jList1ComponentShown(evt);
            }
        });
        jScrollPane1.setViewportView(jList1);

        addStageButton.setText("Add stage...");
        addStageButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addStageButtonActionPerformed(evt);
            }
        });

        removeStageButton.setText("Remove");
        removeStageButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                removeStageButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel11, javax.swing.GroupLayout.DEFAULT_SIZE, 424, Short.MAX_VALUE)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(removeStageButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(addStageButton))
                    .addComponent(jScrollPane1))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(addStageButton)
                    .addComponent(removeStageButton))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 98, Short.MAX_VALUE)
                .addContainerGap())
        );

        jTabbedPane1.addTab("2. Stages", jPanel2);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(okButton, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cancelButton))
                    .addComponent(jTabbedPane1))
                .addContainerGap())
        );

        layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {cancelButton, okButton});

        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cancelButton)
                    .addComponent(okButton))
                .addContainerGap())
        );

        getRootPane().setDefaultButton(okButton);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
        processInput();
        doClose(RET_OK);
    }//GEN-LAST:event_okButtonActionPerformed
    
    private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
        doClose(RET_CANCEL);
    }//GEN-LAST:event_cancelButtonActionPerformed

    /**
     * Closes the dialog
     */
    private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
        doClose(RET_CANCEL);
    }//GEN-LAST:event_closeDialog

    private void addStageButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addStageButtonActionPerformed
        AddCompetitionSportStageDialog dlg = new AddCompetitionSportStageDialog(null, true);
        dlg.setVisible(true);
        if(dlg.getReturnStatus()==AddCompetitionSportStageDialog.RET_OK) {
            DefaultListModel<CompetitionStage> model = (DefaultListModel<CompetitionStage>)jList1.getModel();
            if(model!=null) {
                CompetitionStage stage = dlg.getStage();
                stage.setIndex(model.getSize());
                model.addElement(stage);
            }
        }
    }//GEN-LAST:event_addStageButtonActionPerformed

    private void removeStageButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeStageButtonActionPerformed
        if(jList1.isSelectionEmpty())
            return;
        DefaultListModel<CompetitionStage> model = (DefaultListModel<CompetitionStage>)jList1.getModel();
        if(model==null) return;
        int[] a = jList1.getSelectedIndices();
        for(int i : a) {
            model.removeElementAt(i);
        }
    }//GEN-LAST:event_removeStageButtonActionPerformed

    private void jList1ValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_jList1ValueChanged
        removeStageButton.setEnabled(!jList1.isSelectionEmpty());
    }//GEN-LAST:event_jList1ValueChanged

    private void jList1ComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_jList1ComponentShown
        removeStageButton.setEnabled(!jList1.isSelectionEmpty())
; }//GEN-LAST:event_jList1ComponentShown

    private void jList1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jList1MouseClicked
        if(jList1.isSelectionEmpty()) return;
        if(evt==null||evt.getClickCount()<2) return;
        AddCompetitionSportStageDialog dlg = new AddCompetitionSportStageDialog(null, true, (CompetitionStage)jList1.getSelectedValue());
        dlg.setVisible(true);
        this.repaint();
    }//GEN-LAST:event_jList1MouseClicked

    private void jCheckBox1StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jCheckBox1StateChanged
        maxPeopleSpinner.setEnabled(jCheckBox1.isSelected());
    }//GEN-LAST:event_jCheckBox1StateChanged
    
    private void doClose(int retStatus) {
        returnStatus = retStatus;
        setVisible(false);
        dispose();
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(AddCompetitionSportDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(AddCompetitionSportDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(AddCompetitionSportDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(AddCompetitionSportDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the dialog
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                AddCompetitionSportDialog dialog = new AddCompetitionSportDialog(new javax.swing.JFrame(), true, null);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {

                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton addStageButton;
    private javax.swing.JButton cancelButton;
    private javax.swing.JSpinner dateSpinner;
    private javax.swing.JCheckBox jCheckBox1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JList jList1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JSpinner maxPeopleSpinner;
    private javax.swing.JTextField nameTF;
    private javax.swing.JButton okButton;
    private javax.swing.JButton removeStageButton;
    private javax.swing.JComboBox sportCB;
    // End of variables declaration//GEN-END:variables
    private int returnStatus = RET_CANCEL;
    private CompetitionSport sport;
    private List<CompetitionStage> stages = new ArrayList<>();
}
